<?php
/**
 * CreateUser: zlh
 * CreateTime: 2022/2/6 16:21
 * Remark:
 */

namespace App\Models\File;

use App\Consts\TableConsts\TableConsts;
use Illuminate\Database\Eloquent\Model;

class FileModel extends Model
{
    protected $table = TableConsts::CY_FILE_TABLE_NAME;

    protected $primaryKey = TableConsts::CY_FILE_PRIMARY_KEY;

    protected $fillable = [
        'file_id',
        'file_name',
        'file_url',
        'file_ext',
        'created_up',
        'updated_up',
        'file_mime_type',
        'parent_id'
    ];

    public $timestamps = false;

    public function getFilesByIds($fileIds){
        return $this->whereIn('file_id',$fileIds)->get();
    }

    public function getFilesByIdSelect($fileIds,$select = ["*"]){
        return $this->select($select)->whereIn('file_id',$fileIds)->get();
    }

    public function getFileById($fileId){
        return $this->where('file_id',$fileId)->first();
    }

}